package cn.kgc.mvc.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: mosin
 * @version: v1.0  2022/7/8
 * 全局异常处理类
 */
@ControllerAdvice
//@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ArithmeticException.class)
    public String arithmeticExceptionHandler(Exception exception){
        System.out.println(exception.getMessage());
        return "error";
    }

    @ExceptionHandler(NullPointerException.class)
    public String nullPointerExceptionHandler(Exception exception){
        System.out.println(exception.getMessage());
        return "error2";
    }




}
